﻿namespace OpenComposite.Inbox.Forms
{
	using System;
	using System.Windows.Forms;

	partial class FormSelectPostPoneDt : Form
	{
		#region Initialization

		public FormSelectPostPoneDt(string activityNm)
		{
			InitializeComponent();
			setMinimumDate();
			this.lbActivityNm.Text = activityNm;
		}

		#endregion Initialization

		#region Public Members

		#region Properties

		public DateTime PostponeDate
		{
			get { return getPostPoneDate(); }
		}

		#endregion Properties

		#endregion Public Members

		#region Private Members

		#region Event Handlers

		private void tsbtnCancel_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}

		private void tsbtnOK_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.OK;
			this.Close();
		}

		private void dtpDate_ValueChanged(object sender, EventArgs e)
		{
			DateTime dt = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day,
									   dtpTime.Value.Hour, dtpTime.Value.Minute, 0);
			if ( dt < dtpTime.MinDate )
				dt = dtpTime.MinDate;

			this.dtpTime.Value = dt;
		}

		private void frmSelPostPoneDt_Load(object sender, EventArgs e)
		{
		}

		#endregion Event Handlers

		#region Methods

		private DateTime getPostPoneDate()
		{
			return new DateTime(this.dtpDate.Value.Year, this.dtpDate.Value.Month, this.dtpDate.Value.Day,
								this.dtpTime.Value.Hour, this.dtpTime.Value.Minute, 0, 0);
		}

		private void setMinimumDate()
		{
			DateTime now = DateTime.Now;
			now = now.AddSeconds(-now.Second);
			this.dtpTime.MinDate = now;
			this.dtpDate.MinDate = now;
		}

		#endregion Methods

		#endregion Private Members
	}
}